package org.gstreamer.java.runtime;

import com.sun.jna.Library;
import com.sun.jna.Native;

/** C library functionality. */
public interface CLibrary extends Library {
    
    CLibrary INSTANCE = (CLibrary) Native.loadLibrary("c", CLibrary.class);
    
    /**
     * The setenv() function shall update or add a variable in the environment of the calling process.
     * The function shall fail if envname is a string which contains an '=' character. If the 
     * environment variable named by envname already exists and the value of overwrite is non-zero, 
     * the function shall return success and the environment shall be updated. If the environment 
     * variable named by envname already exists and the value of overwrite is zero, the function 
     * shall return success and the environment shall remain unchanged.
     * 
     * @param envname  the name of an environment variable to be added or altered.
     * @param envval the value.
     * @param overwrite overwrite flag
     * @return Upon successful completion, zero shall be returned. Otherwise, -1 shall be returned, 
     * errno set to indicate the error, and the environment shall be unchanged.
     */
    int setenv(String envname, String envval, int overwrite);
    
    /**
     * The unsetenv() function shall remove an environment variable from the environment 
     * of the calling process. The name argument is a string, which is the name of the 
     * variable to be removed. The named argument shall not contain an '=' character. If the named 
     * variable does not exist in the current environment, the environment shall be unchanged 
     * and the function is considered to have completed successfully.
     * 
     * @param name the name of environment
     * @return Upon successful completion, zero shall be returned. Otherwise, -1 shall be returned, 
     * errno set to indicate the error, and the environment shall be unchanged.
     */
    int unsetenv(String name);
    
    /**
     * The getenv() function shall search the environment of the calling process for the 
     * environment variable name if it exists and return a string value of the 
     * environment variable. If the specified environment variable cannot be found, a null
     * shall be returned.
     * 
     * @param name the name of the environment variable.
     * @return string containing the value for the specified name
     */
    String getenv(String name);
}